import {getWechat,getOauth} from '../wechat'
const client = getWechat();


export const getSignAsync = async (url) => {
    const {ticket} = await client.fetchTicket();
    let params = client.sign(ticket,url);
    console.log(params);
    params.appId = client.appID;
    return params;
}

export const getAuthorizeUrl = (...args) => {
    const oauth = getOauth();
    return oauth.getAuthorizeUrl(...args);
}

export const getUserByCode = async (code) => {
    const oauth = getOauth();
    const {access_token,openid} = await oauth.fetchAccessToken(code);
    const userInfo = await oauth.getUserInfo(access_token,openid);
    return userInfo;
}

